package com.cheng.channelview;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;

public class MainAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        findComponentById(ResourceTable.Id_btn_channerl_view).setClickedListener(v -> {
            jumpAbility(ChannelViewAbility.class.getName());
        });
        findComponentById(ResourceTable.Id_btn_custom_channerl_view).setClickedListener(v -> {
            jumpAbility(CustomChannelAbility.class.getName());
        });
    }

    private void jumpAbility(String abilityName) {
        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                .withBundleName(getBundleName())
                .withAbilityName(abilityName)
                .build();
        intent.setOperation(operation);
        startAbility(intent);
    }
}
